import { createSlice, createAsyncThunk } from '@reduxjs/toolkit'
import { movieListRequest } from '../../api'


export const getMovieList = createAsyncThunk('movie/getMovieList', async () => {
  const result = await movieListRequest()
  console.log(result,'result');
  return result.data.data.list
})
const movieSlice = createSlice({
  name: 'movie',
  initialState: {
    movieList: []
  },
  reducers: {},
  extraReducers:{
    [getMovieList.fulfilled](prev,action){
      // console.log('getMovieList执行了');
      // console.log(prev,action,'prev,action');
      prev.movieList = action.payload
    }
  }

})

export default movieSlice.reducer

